import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthService } from './services/auth.service';
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { OuterLayoutComponent } from './layout/outer-layout/outer-layout.component';
import { InnerLayoutComponent } from './layout/inner-layout/inner-layout.component';

const routes: Routes = [

  { path: '', redirectTo: 'login', pathMatch: 'full' },
  { path: 'login', loadChildren: './login/login.module#LoginModule' },
  { path: 'bs', loadChildren: './routes/bigscreen/bigscreen.module#BigscreenModule' },
  // 零时日志页面（手动输入 /logs 查看）
  // { path: 'logs', loadChildren: './logs(temp)/logs/logs.module#LogsModule' },

  { // 项目外
    path: 'outer',
    component: OuterLayoutComponent,
    canActivate: [AuthService],
    children: [
      // （工作台）
      {
        path: 'dashboard',
        children: [{ path: '', loadChildren: './dashboard/dashboard.module#DashboardModule' }]
      },
      // （企业文件库页面）
      {
        path: 'company-data',
        children: [{ path: '', loadChildren: './routes/company-data/company-data.module#CompanyDataModule' }]
      },
      // (项目列表页)
      {
        path: 'project-type',
        children: [{ path: '', loadChildren: './routes/project-type/project-type.module#ProjectTypeModule' }]
      },
      // (公告页)
      {
        path: 'notice',
        children: [{ path: '', loadChildren: './routes/notice/notice.module#NoticeModule' }]
      },
      // 个人信息
      {
        path: 'personal',
        children: [{ path: '', loadChildren: './routes/personal/personal.module#PersonalModule' }]
      },
      // 修改密码
      {
        path: 'password',
        children: [{ path: '', loadChildren: './routes/password/password.module#PasswordModule' }]
      }
    ]
  },
  { // 项目内（包含项目详情页，组织机构详情页）
    path: 'inner',
    component: InnerLayoutComponent,
    canActivate: [AuthService],
    children: [
      // 项目详情页
      {
        path: 'project',
        children: [{ path: '', loadChildren: './routes/project/project.module#ProjectModule' }]
      },
      // 组织结构
      {
        path: 'oraganization',
        children: [{ path: '', loadChildren: './routes/organization/organization.module#OrganizationModule' }]
      },
    ]
  },
  { path: '**', redirectTo: 'login' }
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes),
    NgZorroAntdModule,
    CommonModule,
    FormsModule
  ],
  declarations: [
    OuterLayoutComponent,
    InnerLayoutComponent,

  ],
  exports: [RouterModule]
})
export class AppRoutingModule { }
